<!--
 * @Description:
 * @Author bianpengfei
 * @create 2022/11/8 22:17
 -->
<template>
  <el-dialog
    v-if="_visible"
    :visible.sync="_visible"
    append-to-body
    width="1110px"
    :title="_title"
    top="50px"
    :close-on-click-modal="false"
  >
    <div class="px-10px">
      <template v-if="model == 1">
        <!-- 新增     -->
        <el-form :model="form" label-width="90px">
          <g-title>基础信息</g-title>
          <el-row>
            <el-col :span="8">
              <el-form-item
                prop="title"
                label="登陆账号"
                :rules="[{ required: true, message: '请输入登陆账号', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入登陆账号" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="姓名"
                :rules="[{ required: true, message: '请输入姓名', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="pass"
                label="密码"
                :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入密码" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="性别"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="出生日期"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="身份证"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="部门"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item
                prop="content"
                label="职称"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="24">
              <el-form-item
                prop="content"
                label="性别"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <g-title>基础信息</g-title>
          <el-row>
            <el-col :span="24">
              <el-form-item
                prop="content"
                label="角色"
                :rules="[{ required: true, message: '请选择', trigger: 'blur' }]"
              >
                <el-input v-model="form.title" placeholder="请输入姓名" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

        <div class="items-center flex justify-center pb-12px">
          <el-button type="primary">保存</el-button>
          <el-button @click="onReset">重置</el-button>
        </div>
      </template>

      <template v-else-if="model == 2">
        <!-- 新增     -->
      </template>
    </div>
  </el-dialog>
</template>

<script>
export default {
  props: {
    visible: {
      type: Boolean,
      default: false
    },

    model: {
      type: [String, Number],
      default: 1 // 1 新增 2 编辑
    }
  },

  data() {
    return {
      form: {
        title: '',
        content: ''
      }
    }
  },

  computed: {
    _title() {
      const conf = {
        1: '新增用户',
        2: '编辑用户'
      }
      return conf[String(this.model)]
    },

    _visible: {
      get() {
        return this.visible
      },
      set(val) {
        this.$emit('update:visible', val)
      }
    }
  },

  watch: {},

  created() {},

  mounted() {
    this.$once('hook:beforeDestroy', () => {
      // this.removeEvents()
    })
  },

  methods: {
    onReset() {
      this.form = {
        ...this.form,
        title: '',
        content: ''
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.page {
}
</style>
